package com.hn.kiss.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hn.kiss.modules.sys.dto.OrganizationPageDTO;
import com.hn.kiss.modules.sys.entity.Organization;
import com.hn.kiss.modules.sys.mapper.OrganizationMapper;
import com.hn.kiss.modules.sys.service.IOrganizationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zxy
 * @since 2020-08-07
 */
@Service
public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, Organization> implements IOrganizationService {

    @Override
    public Organization getByPk(String code) {
        LambdaQueryWrapper<Organization> lambda = new QueryWrapper<Organization>().lambda()
                .eq(Organization::getCode, code);
        return baseMapper.selectOne(lambda);
    }

    @Override
    public boolean updateByPk(Organization organization) {
        LambdaQueryWrapper<Organization> lambda = new QueryWrapper<Organization>().lambda()
                .eq(Organization::getCode, organization.getCode());
        return super.update(organization, lambda);
    }

    @Override
    public boolean removeByPk(String code) {
        LambdaQueryWrapper<Organization> lambda = new QueryWrapper<Organization>().lambda()
                .eq(Organization::getCode, code);
        return super.remove(lambda);
    }

    @Override
    public Page<OrganizationPageDTO> myPage(Page page, Wrapper<Organization> ew) {
        return baseMapper.myPage(page, ew);
    }

    @Override
    public OrganizationPageDTO getDeatilByPk(String code) {
        return baseMapper.selectDeatilByPk(code);
    }

}
